

function index(){

new Vue({
				el: '#app',
				data() {
					return {
						isym:true,
						title: 'Hello',
						codeText: '获取验证码',
						phone: '',
						code: '',
						agent_id: '',
						disabled: true,
						text:''
					}
				},
				mounted: function(){
					let query = location.search;  // ?id=310&name=xia&phone=13800138000

					let searchParams = new URLSearchParams(query);

					if(searchParams.has('agent_id')){
						this.agent_id = searchParams.get('agent_id');
					}

				},
				methods: {
					//获取验证码
					getCode() {
						if (!this.disabled) {
							return
						}
						if (!this.phone) {
							this.text = '手机号不能为空！'
							this.closeTS()
							return
						}
						if (!this.isphone(this.phone)) {
							this.text = '手机号格式不正确！'
							this.closeTS()
							return
						}

						let me = this
						this.$dialog.loading.open('正在加载');
						$.ajax({
							type: "get",
							url: "https://xapp.zkego.com/xapp/userBind/findcode",
							data: {phone: me.phone},
							success: function(res) {
								console.log(res)
								if (res.state) {
									me.getitem()
									me.text = res.msg
									me.closeTS()
								} else {
									me.text = res.msg
									me.closeTS()
								}
								me.$dialog.loading.close();
							}
						})
					},
					isphone(phone) {
						let myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
						if (!myreg.test(phone)) {
							return false
						} else {
							return true
						}
					},

					// 注册
					register() {

						if (!this.phone) {
							this.text = '手机号不能为空！'
							this.closeTS()
							return
						}
						if (!this.isphone(this.phone)) {
							this.text = '手机号格式不正确！'
							this.closeTS()
							return
						}
						if (!this.code) {
							this.text = '手机号格式不正确！'
							this.closeTS()
							return
						}
						let me = this
						this.$dialog.loading.open('正在加载');
						$.ajax({
							type: "get",
							url: "https://xapp.zkego.com/xapp/userBind/extension",
							data: {
								phone: this.phone,
								code: this.code,
								agent_id: this.agent_id ? this.agent_id : ''
							},
							success: function(res) {
								if (res.state) {
									me.isym = false
								} else {

									me.text = res.msg
									me.closeTS()
								}
								me.$dialog.loading.close();
							}
						})
					},
					// 关闭提示框
					closeTS(){
						let me = this
						setTimeout(function() {
							me.text = ''
						}, 2000)
					},
					// 倒计时
					getitem(){
						let me = this
						this.disabled = false
						var currentTime = 60
						var interval = setInterval(function() {
							currentTime--; //每执行一次让倒计时秒数减一
							me.codeText = currentTime + 's后重发' //按钮文字变成倒计时对应秒数
							if (currentTime <= 0) {
								clearInterval(interval)
								me.codeText = '获取验证码'
								me.disabled = true
							}
						}, 1000);
					},
					XZ(){
						window.location.href='https://downloadpkg.app3c.cn/app/download?path=http://zhongke.down.shandian001.com/c12e9ade9f8e203e2a41c0168594155a_d'
					}
					
					


				}
			})
}


